//
//  DeterenceBackAnimationView.m
//  safeLady
//
//  Created by xmy on 2017/1/11.
//  Copyright © 2017年 xmy. All rights reserved.
//

#import "DeterenceBackAnimationView.h"
@interface DeterenceBackAnimationView ()
@property (weak, nonatomic) IBOutlet UIImageView *animation_image_one;
@property (weak, nonatomic) IBOutlet UIImageView *animation_image_two;


@end
@implementation DeterenceBackAnimationView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)awakeFromNib{
    [super awakeFromNib];
    [self setBackGroundImgAnimationOne];
    [self setBackGroundImgAnimationTwo];
}

-(void)setBackGroundImgAnimationOne{
    CABasicAnimation *transform = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];//同上
    transform.toValue =  [NSNumber numberWithFloat: M_PI *2];
    transform.duration = 6.5f;
    transform.repeatCount = MAXFLOAT;
    transform.removedOnCompletion = NO;//要做无限循环的动画，动画的removedOnCompletion属性必须设置为NO，否则运行一次动画就会销毁。
    [self.animation_image_one.layer addAnimation:transform forKey:@"transformAnimationOne"];
}

-(void)setBackGroundImgAnimationTwo{
    CABasicAnimation *transform = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];//同上
    transform.fromValue =  [NSNumber numberWithFloat: M_PI *2];
    transform.toValue =  [NSNumber numberWithFloat: 0.f];
    transform.duration = 6.5f;
    transform.repeatCount = MAXFLOAT;
    transform.removedOnCompletion = NO;
    [self.animation_image_two.layer addAnimation:transform forKey:@"transformAnimationtwo"];
}
@end
